home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
DONALDXC
/
FILEOPEN.C
< prev
next >
Wrap
Text File
|
1990-05-01
|
1KB
|
56 lines
/********************************/
/* File: FIleOpen.c */
/* */
/* open the file whose name and */
/* working directory id are */
/* passed as parameters. This */
/* information can be obtained */
/* using GetFileNameToLoad... */
/* */
/* Paramters: */
/* param0 = file name num */
/* param1 = directory id */
/* */
/* Out: */
/* File RefNum if opened, 0 */
/* otherwise */
/* ---------------------------- */
/********************************/
#include <MacTypes.h>
#include <OSUtil.h>
#include <MemoryMgr.h>
#include <FileMgr.h>
#include <ResourceMgr.h>
#include <pascal.h>
#include <string.h>
#include "HyperXCmd.h"
#include "HyperUtils.h"
pascal void main( paramPtr )
XCmdBlockPtr paramPtr;
{
char *filename;
Str31 str, fName;
short wdid, refnum;
HLock( paramPtr->params[0] );
ZeroToPas( paramPtr, *(paramPtr->params[0]), &fName );
HUnlock( paramPtr->params[0] );
/* convert the wdid to a usable form */
HLock( paramPtr->params[1] );
ZeroToPas( paramPtr, *(paramPtr->params[1]), &str );
HUnlock( paramPtr->params[1] );
wdid = (short)StrToNum( paramPtr, &str );
if( FSOpen( &fName, wdid, &refnum) == noErr )
NumToStr( paramPtr, (long)refnum, &str );
else
str.data[0] = '\0'; /* return empty if not opening */
paramPtr->returnValue = PasToZero( paramPtr, &str );
}